<?php
/**
 * 热门城市模型
 */

namespace app\official\model;


use app\common\model\BaseModel;
use PDOStatement;
use think\Collection;
use think\db\exception\DataNotFoundException;
use think\db\exception\ModelNotFoundException;
use think\exception\DbException;

class HotCity extends BaseModel {

    /**
     * 热门城市
     * @return array|PDOStatement|string|Collection
     * @throws DataNotFoundException
     * @throws ModelNotFoundException
     * @throws DbException
     */
    public static function getList() {
        $data = db('hot_city')
            ->field('city_code,name,x(location) as lng,Y(location) as lat')
            ->select();
        foreach ($data as $k => $v) {
            $data[$k]['lng'] = empty($data[$k]['lng']) ? '' : (string)$v['lng'];
            $data[$k]['lat'] = empty($data[$k]['lat']) ? '' : (string)$v['lat'];
        }
        return $data;
    }

}
